<template>
    <div class="app-container">
        <div class="filter-container" ref="searchForm">
            <div slot="header" class="clearfix">
                <el-button class="toolbar-btn" @click="sortTable()">排序</el-button>
            </div>
            <elTable ref="dataInfo" :enterSearch="true" :formData="formData" @tableData="getList">
                <el-table-column prop="goodsName" label="活动名称名称" align="center"></el-table-column>
                <el-table-column prop="activityBanner" label="活动banner" align="center"></el-table-column>
                <el-table-column prop="startTime" label="开始时间" align="center"></el-table-column>
                <el-table-column prop="endTime" label="结束时间" align="center"></el-table-column>
                <!-- 新品、控销 -->
                <el-table-column label="操作" align="center">
                    <template slot-scope="{row,$index}">
                        <el-button type="primary" size="mini" @click="uploadPicture(row)">上传楼层宣传图</el-button>
                        <el-button type="primary" size="mini" @click="lookGoods(row)">查看商品</el-button>
                    </template>
                </el-table-column>
            </elTable>
            <sortTable ref="sortTable"></sortTable>
            <!-- 上传楼层宣传图 -->
            <div id="dialogAdvertisingPicture">
                <el-dialog
                    v-if="dialogFormVisible"
                    :visible.sync="dialogFormVisible"
                    title="上传楼层宣传图"
                    width="620px"
                    :close-on-click-modal="false"
                >
                    <el-form
                        ref="subForm"
                        :inline="true"
                        :model="submitFormData"
                        class="search-form-inline"
                        label-width="110px"
                        size="small"
                        :label-position="labelPosition"
                    >
                        <el-form-item>
                            <elUpload
                                ref="upload"
                                :autoUpload="false"
                                :fileList="fileList"
                                :dragable="false"
                            ></elUpload>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取 消</el-button>
                        <el-button type="primary" @click="submitForm">确 定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</template>
<script>
import sortTable from "@/dialog/table/tableSort"; //表格排序框
import apisActivityMessage from "@/api/shopDecoration/activityMessage"; //活动管理列表接口
import elTable from "@/components/xForm/elTable";
import elUpload from "@/components/xForm/elUpload";
export default {
    name: "activityMessage",
    components: { sortTable, apisActivityMessage, elTable, elUpload },
    data() {
        return {
            formData: {
                currentPage: 1,
                pageSize: 10,
            },

            dataInfo: [],
            floorType: "", //楼层类型

            submitFormData:{},
            dialogFormVisible: false,
            labelPosition: "right", // 上传图片
            fileList: [],
        };
    },
    mounted() {
        this.floorType = this.$route.query.floorType; //获取楼层类型
        // this.dataInfo = this.$refs.dataInfo;
    },
    methods: {
        getList(pageNo) {
            let _this = this;
            _this.formData.currentPage = pageNo || _this.formData.currentPage;
            _this.formData.templateId = _this.$route.query.templateId;
            let dataInfo = [
                {
                    id: 1,
                    goodsName: "5月联联购1",
                    floorType: 1,
                },
            ];
            let total = 10;
            this.$nextTick(() => {
                this.$refs.dataInfo.loadData(dataInfo, total);
            });
            // apisActivityMessage.activityMessageList(this.formData).then(res=>{
            //     _this.dataInfo.loadData(res.data.list, res.data.total);
            // })
        },
        // 上传楼层宣传图
        uploadPicture(row) {
            this.dialogFormVisible = true;
        },
        // 查看商品
        lookGoods(row) {
            this.$router.push({
                path: [
                    "/shopDecoration/goodsMessage",
                    row.id,
                    "商品管理:" + row.goodsName,
                ].join("/"),
                query: { templateId: row.id, floorType: row.floorType },
            });
        },
        // 排序
        sortTable() {
            this.dataInfo.sortTable({
                dataUrl: "/enterAreaGoodsMessage/list",
                sortUrl: "/enterAreaGoodsMessage/doSort",
                callback: () => {
                    this.getList();
                },
            });
        },

        submitForm(){}
    },
};
</script>

<style lang="" scoped>
</style>
